package com.aaa.controller;

import com.aaa.pojo.Ptype;
import com.aaa.service.PtypeService;
import com.aaa.util.DefaultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品类别管理控制器
 */
@RestController
@RequestMapping("/ptype")
public class PtypeController {


    @Autowired
    private PtypeService ptyqeService;

    /**
     *查询所有的商品类别信息
     * @return
     */
    @RequestMapping("/listAll")
    public List<Ptype> listAll(){
        return ptyqeService.listAll();
    }

    /**
     * 保存或者根据商品id修改类别管理
     * @param ptype
     * @return
     */
    @RequestMapping("/saveOrUpdate")
    public DefaultMsg saveOrUpdate(Ptype ptype){
        DefaultMsg defaultMsg = ptyqeService.saveOrUpdate(ptype);
        return defaultMsg;
    }

    @RequestMapping("/del")
    public Integer delete(Integer tid){
        return ptyqeService.del(tid);
    }
}
